package com.tjsinfo.tjsoa.system.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;

public class UpatePasswordAction extends Action {
	private ISystemUserBo systemUserBo;

	public void setSystemUserBo(ISystemUserBo systemUserBo) {
		this.systemUserBo = systemUserBo;
	}

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		Integer id = Integer.valueOf(request.getParameter("id"));
		
		String password = request.getParameter("password1");
		
		TSystemUser user = systemUserBo.findByIdSystemUser(id);
		user.setPassword(password);
		String url = "error";
		String str = "修改密码失败，请重新进行操作！";
		try {
			systemUserBo.updateSystemUser(user);
			url = "ok";
			str = "修改密码成功！";
		} catch (RuntimeException e) {
		}
		request.setAttribute("linkurl", "tjsinfo/tjsoa/system/main.do");
		request.setAttribute("message", "system.userUpdate.message");
		return mapping.findForward("success");
	}
}
